package com.example.a10928.weifriend.adapter

import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.example.a10928.weifriend.R
import com.example.a10928.weifriend.http.api.base.WalletFlowBean
import com.squareup.picasso.Picasso
import kotlinx.android.synthetic.main.item_wallet.view.*

import java.util.ArrayList

class MyWalletAdapter(layoutResId: Int, data: MutableList<WalletFlowBean.MoneyFlowBean>) : BaseQuickAdapter<WalletFlowBean.MoneyFlowBean, BaseViewHolder>(layoutResId, data) {

    override fun convert(helper: BaseViewHolder, item: WalletFlowBean.MoneyFlowBean) {

        if(item.flow_type==1){
            helper.setText(R.id.tv_value,"+"+item.flow_amount)
            if(item.income_type==1){
                helper.setText(R.id.tv_sort,"直推推荐奖")

                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.task)
            } else if(item.income_type==2){
                helper.setText(R.id.tv_sort,"间接推荐奖")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.commission)
            } else if(item.income_type==3){
                helper.setText(R.id.tv_sort,"上推贡献奖")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.commission)
            } else if(item.income_type==4){
                helper.setText(R.id.tv_sort,"每日领取补贴")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.commission)
            } else if(item.income_type==5){
                helper.setText(R.id.tv_sort,"直推补贴奖励")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.commission)
            } else if(item.income_type==6){
                helper.setText(R.id.tv_sort,"间接补贴奖励")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.drawable.commission)
            }


        }else{
            helper.setText(R.id.tv_value,"-"+item.flow_amount)
            if(item.expend_type==1){
                helper.setText(R.id.tv_sort,"提现")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.mipmap.withdraw)
            }else if(item.expend_type==2){
                helper.setText(R.id.tv_sort,"购买广告")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.mipmap.send_adert)
            }else if(item.expend_type==3){
                helper.setText(R.id.tv_sort,"购买VIP")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.mipmap.buy_vip)
            }else if(item.expend_type==4){
                helper.setText(R.id.tv_sort,"一元夺宝")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.mipmap.buy_vip)
            }else if(item.expend_type==0){
                helper.setText(R.id.tv_sort,"未知")
                helper.getView<ImageView>(R.id.iv).setImageResource(R.mipmap.buy_vip)
            }
        }
        helper.setText(R.id.tv_describe,item.content)
/*

        if(item.check_status==0){
            helper.setText(R.id.tv_describe,"审核中")
        }else if(item.check_status==1){
            helper.setText(R.id.tv_describe,"通过")
        }else {
            helper.setText(R.id.tv_describe,"拒绝").setText(R.id.tv_value,"0")
        }
*/

        helper.setText(R.id.tv_time,item.updated_at)


    }
}
